﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;

namespace eLuk.Entity
{
	[DataContract( IsReference = true )]
	public class eLukSubComponent
	{
		[DataMember]
		public static List<KeyValuePair<string, Type>> GroupViews { get; set; }

		public eLukSubComponent()
		{
			//this.Groups = new eLukGroups();
			//if ( eLukGroup.GroupViews == null )
			//	eLukGroup.GroupViews = new List<KeyValuePair<string, Type>>();
		}

		public eLukSubComponent( string uniqueId, string title, string subtitle, string imagePath, string description, eLukObject eLukObject )
			: this()
		{
			this.UniqueId = uniqueId;
			this.Title = title;
			this.Subtitle = subtitle;
			this.Description = description;
			this.ImagePath = imagePath;
			string[] formats = DateTime.Now.GetDateTimeFormats();
			this.LastRefreshDate = formats.Length > 14 ? formats[ 14 ] : DateTime.Now.ToString();
			this.eLukObject = eLukObject;
		}

		[DataMember]
		public string UniqueId { get; set; }

		[DataMember]
		public string Title { get; set; }

		[DataMember]
		public string Subtitle { get; set; }

		[DataMember]
		public string Description { get; set; }

		[DataMember]
		public string ImagePath { get; set; }

		[DataMember]
		public string LastRefreshDate { get; set; }

		public Type GroupView
		{
			get
			{
				return eLukSubComponent.GroupViews.Find( g => g.Key == this.UniqueId ).Value;
			}
		}

		[DataMember]
		public eLukObject eLukObject { get; set; }

		public override string ToString()
		{
			return this.Title;
		}

		//[DataMember]
		//public Page PrimaryView { get; set; }

	}

	[CollectionDataContract( IsReference = true )]
	public class eLukSubComponents : List<eLukSubComponent>
	{
		public eLukSubComponents()
		{
		}
	}
}
